#include"EventLoop.h"
#include"channel.h"
#include"myepoll.h"
#include<iostream>
#include<thread>
#include<map>
#include"TcpConnection.h"
#include"sever.h"

EventLoop::EventLoop(/* args */)
{
    ep = new myepoll();
}

EventLoop::~EventLoop()
{
    delete ep;
}

void EventLoop::loop()
{
    while(1){
        std::vector<MyChannel*> activeEvent = ep->poll();
        for(int i = 0;i<activeEvent.size();i++){
            // std::cout<<"从reactor"<<std::this_thread::get_id()<<std::endl;
            activeEvent[i]->headleEvent();
        }
    }
}

void EventLoop::updateChannel(MyChannel *ch)
{
    ep->updateChannel(ch);
}
